$(document).ready(function() {
    var height = (window.innerHeight > 0) ? window.innerHeight : screen.height;
    var width = (window.innerWidth > 0) ? window.innerWidth : screen.width;
    //弹出信封
    var wrap = $("#wrap");
    var envelope = $("#envelope");
    wrap.tap(function(e) {
        e.preventDefault();
        // var envelope = $("#envelope");
        var temp = height * 0.8;
        envelope.animate({
            "translateY": -temp + "px"
        }, 500, function() {
            var hint = $("#hint-info");
            hint.hide();
        });
    });
    //滑出信纸内容
    var timer;
    var index;
    envelope.tap(function() {
        var content = $(".cotent");
        var num = Math.ceil((Math.random() * 10) % 5);
        if (num == 0) {
            index = 0;
        } else {
            index = num - 1;
        }
        console.log(index);
        var content = $(".content");
        content.eq(index).animate({
            "translateX": -width + "px"
        }, 600, "ease-in-out", function() {
            timer = setTimeout(function() {
                var fool = $("#fool-info");
                var temp = width;
                fool.animate({
                    "translateX": temp + "px"
                }, 400, "ease-in");
            }, 60000);
        });
    });
    //弹出愚人节信息
    var button = $(".click-button");
    button.tap(function() {
        var fool = $("#fool-info");
        var temp = width;
        fool.animate({
            "translateX": temp + "px"
        }, 400, "ease-in");
    });
    //关闭窗口
    var tip = $("#tip");
    tip.tap(function() {
        var foolInfo = $("#fool-info");
        foolInfo.css({
            "-webkit-transform": "translateX(" + "-" + width + "px)"
        });
        clearTimeout(timer);
    });
});
